<template>
	<div ref="rightClickmenuListRef" class="rightClickmenuList" v-if="this.newRightMenuObj.menuList!==undefined">
		<ul>
			<li v-for="item in this.newRightMenuObj.menuList" :key="item.value" @click="menuItemClick(item)">{{item.label}}</li>
		</ul>
	</div>
</template>
<script>

export default {
	name: 'rightClickmenuList',
	props: ['rightMenuObj'],
	data() {
		return {
			newRightMenuObj: this.rightMenuObj,
			ticketType:this.$store.state.setTicketType,
			mainPage:[
				{value: 1, label:'故障设置'},
				{value: 2, label:'合闸'},
					{value: 3, label:'分闸'},
			],
			mainPage_1:[
				{value: 1, label:'故障设置'},
			],
			mainPage_2:[
				{value: 2, label:'合闸'},
					{value: 3, label:'分闸'},
			],
			// 断路器右击菜单
			duanluqiMenuList: [
				{value: 1, label:'遥控'},
				// {value: 2, label:'开关清闪'},
				// {value: 3, label:'全站清闪'},
				// // {value: 5, label:'故障设置'},
				// {value: 6, label:'挂牌/摘牌'},
			],
			// 1号主变 2号主变右键菜单
			mainTransformerMenuList: [
				{value: 1, label:'故障设置'}
			],
			// 隔离刀 - 右击菜单
			gelidaoMenuList: [
				{value: 1, label:'遥控'},
				// {value: 5, label:'故障设置'},
				// {value: 6, label:'挂牌/摘牌'},
			],
			// 地刀 - 右击菜单
			didaoMenuList: [
				{value: 1, label:'遥控'},
				// {value: 3, label:'故障设置'},
				// {value: 5, label:'挂牌/摘牌'},
			],
			// 把手
			bashouMenuList: [
			],
			shoucheMenuList: [
			],
			// 遥测量
			yaoceliangMenuList: [
				{value: 1, label:'状态检查'},
			],
			// 硬压板
			yingyabanMenuList: [
				{value: 2, label:'状态检查'},
			],
			// 间隔链路
			jiangelianluMenuList: [
			],
			ruanyabanMenuList: [
				{value: 1, label:'遥控'},
			],
			// 1号主变
		}
	},
	created() {
	},
	methods: {
		menuItemClick(item) {
			this.$emit('menuItemClick',item)
		}
	},
	computed:{
		isMain() {
			return this.$store.state.isMainPage
		},
	},
	watch: {
		rightMenuObj: {
			handler(newValue) {
				if(newValue) {
					this.newRightMenuObj = newValue
					if (this.isMain===true&&this.ticketType==='图形开票'&&this.newRightMenuObj.isMainPage &&(this.newRightMenuObj.type==='duanluqi')){
						this.newRightMenuObj.menuList = this.mainPage
						this.$nextTick(() => {
							this.$refs.rightClickmenuListRef.style.top = this.newRightMenuObj.clientY + 'px'
							this.$refs.rightClickmenuListRef.style.left = this.newRightMenuObj.clientX + 'px'
						})

					}else if (this.newRightMenuObj.isMainPage&&(this.newRightMenuObj.type==='muxian'||this.newRightMenuObj.type==='xianlu'||this.newRightMenuObj.type==='bianyaqi'||this.newRightMenuObj.type==='zhanyongbian'||this.newRightMenuObj.type==='duanluqi'||this.newRightMenuObj.type==='dianrongqi'||this.newRightMenuObj.type==='diankangqi')){
						this.newRightMenuObj.menuList = this.mainPage_1
						this.$nextTick(() => {
							this.$refs.rightClickmenuListRef.style.top = this.newRightMenuObj.clientY + 'px'
							this.$refs.rightClickmenuListRef.style.left = this.newRightMenuObj.clientX + 'px'
						})
					}else if(this.isMain===true&&this.ticketType==='图形开票'&&this.newRightMenuObj.isMainPage&&(this.newRightMenuObj.type==='didao'||this.newRightMenuObj.type==='gelidao')){
						this.newRightMenuObj.menuList = this.mainPage_2
						this.$nextTick(() => {
							this.$refs.rightClickmenuListRef.style.top = this.newRightMenuObj.clientY + 'px'
							this.$refs.rightClickmenuListRef.style.left = this.newRightMenuObj.clientX + 'px'
						})
					}else if (!this.newRightMenuObj.isMainPage){
						if(this.newRightMenuObj.type == 'duanluqi'){
							this.newRightMenuObj.menuList = this.duanluqiMenuList
						}
						if(this.newRightMenuObj.type == 'zhubian#1' || this.newRightMenuObj.type == 'zhubian#2'){
							this.newRightMenuObj.menuList = this.mainTransformerMenuList
						}
						if(this.newRightMenuObj.type == 'gelidao'){
							this.newRightMenuObj.menuList = this.gelidaoMenuList
						}
						if(this.newRightMenuObj.type == 'didao'){
							this.newRightMenuObj.menuList = this.didaoMenuList
						}
						if(this.newRightMenuObj.type == 'bashou'){
							this.newRightMenuObj.menuList = this.bashouMenuList
						}
						if(this.newRightMenuObj.type == 'yaoceliang'){
							this.newRightMenuObj.menuList = this.yaoceliangMenuList
						}
						if(this.newRightMenuObj.type == 'yingyaban'){
							this.newRightMenuObj.menuList = this.yingyabanMenuList
						}
						if(this.newRightMenuObj.type == 'jiangelianlu'){
							this.newRightMenuObj.menuList = this.jiangelianluMenuList
						}
						if(this.newRightMenuObj.type == 'ruanyaban'){
							this.newRightMenuObj.menuList = this.ruanyabanMenuList
						}
						if (this.newRightMenuObj.type == 'shouche'){
							this.newRightMenuObj.menuList = this.shoucheMenuList
						}
						this.$nextTick(() => {
							this.$refs.rightClickmenuListRef.style.top = this.newRightMenuObj.clientY + 'px'
							this.$refs.rightClickmenuListRef.style.left = this.newRightMenuObj.clientX + 'px'
						})

					}


				}
			},
			deep: true,
			immediate: true
		},
		ticketType(newValue) {
			this.ticketType=newValue
		}
	}
}

</script>

<style lang="less"  scoped>
.rightClickmenuList {
	width: 110px;
	padding: 6px 0;
	background-color: #fff;
	border: 1px solid #d0d0d0;
	border-radius: 8px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	position: fixed;
	user-select: none;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	box-sizing: border-box;
	z-index: 999;

	ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}

	li {
		padding: 8px 16px;
		cursor: pointer;
		transition: background-color 0.2s ease;
		display: flex;
		align-items: center;
		color: #333;
		white-space: nowrap;

		&:hover {
			background-color: #f0f0f0;
		}

		&:active {
			background-color: #e0e0e0;
		}
	}
}

</style>
